<%@page import="pl.org.waff.repository.*"%>
<%@page import="pl.org.waff.WaffServlet"%>
<%@page import="java.util.Set, java.util.Iterator, java.util.ArrayList" %>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<jsp:useBean id="repository" class="pl.org.waff.repository.InMemoryContentCache" scope="application" />
<jsp:useBean id="cmswitch" class="pl.org.waff.cm.CMSwitch" scope="session" />
<div>
    <table width="100%">
        <tr><td>Title</td><td>Author</td><td>Modified</td><td>Status</td><td>Target</td></tr>
        <%
            String tmpPath = cmswitch.getPath();
            if (tmpPath == null) {
                tmpPath = "/";
            }
            ArrayList list = repository.findDocuments(tmpPath, null, null, null);
            Document doc;
            String docId;
            for (int i = 0; i < list.size(); i++) {
                docId = (String) list.get(i);
                doc = repository.getDocument(docId);
                if (doc != null) {
                    out.print("<tr>");
                    out.print("<td><a href='cmswitch.do?view=d&docid=" + doc.getId() + "'>" + doc.getTitle() + "</a></td>");
                    out.print("<td>" + doc.getAuthor() + "</td>");
                    out.print("<td>" + doc.getModifiedAsString("yyyy-MM-dd HH:mm") + "</td>");
                    out.print("<td>" + doc.getStatus() + "</td>");
                    out.print("<td>" + doc.getTarget() + "</td>");
                    out.print("</tr>");
                }
            }
        %>
    </table>
</div>
